<!DOCTYPE html>
<html>
<head>
    <meta name="layout" content="main"/>
    <g:set var="entityName" value="${message(code: 'WorkflowInstance.label', default: 'WorkflowInstance')}"/>
    <title>押品流程管理</title>
</head>

<body>
<div class="small-header">
    <div class="hpanel">
        <div class="panel-body">
            <div id="hbreadcrumb" class="pull-right">
                <ol class="hbreadcrumb breadcrumb">
                    <li>CINDATA PLS</li>
                    <li class="active">
                        <span><g:link action="index">流程管理</g:link></span>
                    </li>
                    <li>
                        <span>押品流程管理</span>
                    </li>
                </ol>
            </div>

            <h2 class="font-light m-b-xs">
                押品流程管理
            </h2>
        </div>
    </div>
</div>

<div class="content animate-panel">

    <div class="row">
        <g:form method="POST" action="collateralWorkflowInstance" class="form-horizontal" role="form" id="form">
            <div class="hpanel hblue">
                <div class="panel-heading">
                    <div class="panel-tools">
                        <button class="btn btn-primary btn-xs" type="submit"><i class="fa fa-search"></i> 查询</button>
                        <button class="btn btn-warning2 btn-xs" type="button" id="resetBtn">
                            <i class="fa fa-times"></i> 重置</button>
                    </div>
                    查询
                </div>
                <div class="panel-body seach-group" id="bug1">
                    %{--第一行--}%
                    <div class="row">
                        <div class="form-group col-sm-3">
                            <label class="col-sm-3 control-label">押品编号</label>
                            <div class="col-sm-9">
                                <input type="text" class="form-control" name="externalId" id="externalId" value="${params?.externalId}" placeholder="请输入押品编号">
                            </div>
                        </div>
                        <div class="form-group col-sm-3">
                            <label class="col-sm-3 control-label">工作流</label>
                            <div class="col-sm-9">
                                <g:select class="form-control" name="workflow" id="workflow"
                                          from="${com.cindata.Workflow.findAllByType(com.cindata.dictionary.WorkflowType.findByName('押品'))}"
                                          valueMessagePrefix="type" optionKey="id" optionValue="name"
                                          value="${params?.workflow}"
                                          noSelection="${['': '请选择工作流']}"/>
                            </div>
                        </div>
                        <div class="form-group col-sm-3">
                            <label class="col-sm-3 control-label">发起人</label>
                            <div class="col-sm-9">
                                <g:select class="form-control" name="createBy" id="createBy" from="${com.cindata.User.list()}" optionKey="id" optionValue="fullName" value="${params?.createBy}"
                                    noSelection="${['': '请选择发起人']}"/>
                            </div>
                        </div>
                        <div class="form-group col-sm-3">
                            <label class="col-sm-3 control-label">审批状态</label>
                            <div class="col-sm-9 district">
                                <g:select class="form-control" name="status" id="status" from="${com.cindata.WorkflowInstanceStatus.list()}" optionKey="id" optionValue="name" value="${params?.status}"
                                    noSelection="${['': '请选择审批状态']}"/>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </g:form>
    </div>

    <div class="row">
        <div class="hpanel hgreen">
            <div class="panel-heading">
                <div class="panel-tools">
                </div>
                工作流
            </div>
            <div class="panel-body no-padding">
                <div class="table-responsive">
                    <table class="table table-striped table-bordered table-hover text-center">
                        <thead>
                        <tr>
                            <g:sortableColumn property="externalId" title="${message(code: 'WorkflowInstance.externalId.label', default: '押品编号')}"/>
                            <g:sortableColumn property="workflow" title="${message(code: 'WorkflowInstance.workflow.label', default: '工作流')}"/>
                            <g:sortableColumn property="createBy" title="${message(code: 'WorkflowInstance.createBy.label', default: '发起人')}"/>
                            <g:sortableColumn property="startTime" title="${message(code: 'WorkflowInstance.startTime.label', default: '发起时间')}"/>
                            <g:sortableColumn property="endTime" title="${message(code: 'WorkflowInstance.endTime.label', default: '结束时间')}"/>
                            <g:sortableColumn property="stage" title="${message(code: 'WorkflowInstance.stage.name.label', default: '当前阶段')}"/>
                            <g:sortableColumn property="role" title="${message(code: 'WorkflowInstance.role.name.label', default: '当前处理角色')}"/>
                            <g:sortableColumn property="status" title="${message(code: 'WorkflowInstance.status.label', default: '审批状态')}"/>
                        </tr>
                        </thead>
                        <tbody>
                        <g:each in="${workflowInstanceList}">
                            <tr>
                                <td><g:link controller="estate" action="show" id="${it?.collateral?.id}">${it?.collateral?.externalId}</g:link></td>
                                <td>${it?.workflow?.name}</td>
                                <td>${it?.createBy?.fullName}</td>
                                <td><g:formatDate date="${it?.createdDate}" format="yyyy-MM-dd HH:mm:ss"></g:formatDate></td>
                                <td><g:formatDate date="${it?.modifiedDate}" format="yyyy-MM-dd HH:mm:ss"></g:formatDate></td>
                                <td>${it?.stage?.name}</td>
                                <td>${com.cindata.WorkflowInstanceUser.findByStageAndAuthority(it?.stage, com.cindata.WorkflowAuthority.findByName('Approval'))*.user?.fullName?.toString()?.substring(1, com.cindata.WorkflowInstanceUser.findByStageAndAuthority(it?.stage, com.cindata.WorkflowAuthority.findByName('Approval'))*.user?.fullName?.toString()?.lastIndexOf(']'))}</td>
                                <td>${it?.status?.name}</td>
                            </tr>
                        </g:each>
                        </tbody>
                    </table>
                </div>
            </div>

            <div class="panel-footer">
                <div class="pagination">
                    <g:paginate action="collateralWorkflowInstance" total="${WorkflowInstanceCount ?: 0}" params="${params}"/>
                </div>
            </div>
        </div>
    </div>
</div>

<g:javascript>
    $(function () {
        //重置按钮
        $("#resetBtn").click(function () {
            $("#externalId").val("");
            $("#s2id_workflow span:first").html("请选择工作流");
            $("#workflow").val("");
            $("#s2id_createBy span:first").html("请选择发起人");
            $("#createBy").val("");
            $("#s2id_status span:first").html("请选择审批状态");
            $("#status").val("");
        });
    });

</g:javascript>

</body>
</html>
